//
//  ZZMainViewController.swift
//  网易微博
//
//  Created by gazyy1 on 16/6/23.
//  Copyright © 2016年 gazyy1. All rights reserved.
//

import UIKit

class ZZMainViewController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
        //设置自定义的tabBar
        let tabBar = ZZTabBar()
        tabBar.zzDelegate = self
        setValue(tabBar, forKey: "tabBar")

        //添加子控制器
        addChildViewControllerInfo(ZZHomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewControllerInfo(ZZMessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewControllerInfo(ZZDiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewControllerInfo(ZZProfileTableViewController(), title: "我的", imageName: "tabbar_profile")
   
    //设置主题颜色
        ZZTabBar.appearance().tintColor = UIColor.orangeColor()
    
    }

    //定义方法添加子控制器
    private func addChildViewControllerInfo(controller : UITableViewController ,title : String,imageName : String){
       
        controller.tabBarItem.title = "\(title)"
        controller.tabBarItem.image = UIImage(named: imageName)
        controller.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        controller.title = title
        
        let navC = UINavigationController(rootViewController: controller)
        navC.view.tintColor = TemColor
        
        addChildViewController(navC)

    }
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
}

extension ZZMainViewController : ZZTabBarDelegate {
    
    func centerButtonClick() {
        print("中间按钮点击了")
    }

}




